package com.datas.beans;

import lombok.Getter;
import lombok.Setter;
import org.json.JSONObject;

/**
 * Created by jige0727 on 2017/5/28.
 */
@Getter
@Setter
public class ActResult {
    String msg;
    Integer success;

    public ActResult(Integer success, String msg) {
        this.msg = msg;
        this.success = success;
    }

    public ActResult(Integer success, String goodMsg, String badMsg) {
        if (success == null || success == 0) {
            this.msg = badMsg;
        } else {
            this.msg = goodMsg;
        }
        this.success = success;
    }

    public JSONObject toJSON() {
        return new JSONObject()
                .put("msg", msg == null ? "" : msg)
                .put("success", success == null ? 0 : success);
    }

    public String toJSONString() {
        return toJSON().toString();
    }
}
